package com.ibeeking.found.cop.b.rest.service.impl;

import com.ibeeking.found.common.constants.MqTopic;
import com.ibeeking.found.cop.b.rest.service.IMqService;
import com.ibeeking.found.cop.b.rest.service.mq.CopMqProducer;
import com.ibeeking.found.cop.service.common.param.*;
import com.ibeeking.nematos.log.utils.LogUtils;
import com.ibeeking.nematos.rocketmq.base.MessageBuilder;
import com.ibeeking.nematos.utils.data.ParamCheckUtils;
import com.ibeeking.nematos.utils.json.JsonUtils;
import org.apache.rocketmq.common.message.Message;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;


@Service
public class MqServiceImpl implements IMqService {

    @Resource
    private CopMqProducer copMqProducer;

    @Async
    @Override
    public void sendSyncToWxTaskMessage(MqSyncCopParam param) {
        try {
            ParamCheckUtils.check(param);
            Message message = MessageBuilder.of(param).topic(MqTopic.COP_SYNC_TO_WXCP_TOPIC).build();
            copMqProducer.syncSend(message);
        } catch (Exception e) {
            LogUtils.error("发送同步客服账号任务Mq消息异常:{}", e);
        }
    }

}
